package de.homelabs.hlmodules.cms.api.template.service;

import java.io.IOException;
import java.io.Reader;

import de.homelabs.hlmodules.cms.configuration.domain.HLConfigurationEntity;
import de.homelabs.hlmodules.cms.template.domain.HLTemplate;
import de.homelabs.hlmodules.cms.template.domain.HLTemplateException;

/**
 * Describes function extended by those from freemarker.cache.TemplateLoader
 * 
 * @author D.Mueller
 * 
 */
public interface IHLTemplateImportStrategy {

	/**
	 * tries to find the requested template with given name
	 * 
	 * @param name
	 *            - Template Name
	 * @return HLTemplate
	 */
	public HLTemplate findTemplateSource(HLConfigurationEntity configEntity,
			String normalizedDomain, String name) throws HLTemplateException;

	/**
	 * gets the last modification for a Template
	 */
	public long getLastModified(HLTemplate templateSource) throws HLTemplateException;

	/**
	 * returns a reader for the template content
	 * 
	 * @param templateSource
	 *            - HLTemplate
	 * @param encoding
	 *            - encoding
	 * @return Reader - content reader
	 */
	public Reader getReader(HLTemplate templateSource, String encoding)
			throws HLTemplateException;

	/**
	 * closes the template
	 * 
	 * @param templateSource
	 * @throws IOException
	 */
	public void closeTemplateSource(HLTemplate templateSource)
			throws HLTemplateException;

}
